package main

import "fmt"

type Student struct {
	name string
	age  int
}
type People struct {
	name  string
	child *People
}
type Command struct {
	Name    string // 指令名称
	Var     *int   // 指令绑定的变量
	Comment string // 指令的注释
}
type A struct {
	ax, ay int
}
type B struct {
	A
	bx, by float32
}

func MakeStruct() {
	var s Student
	s.age = 10
	s.name = "小明"
	fmt.Println(s.name, "--", s.age)
	var s2 Student = Student{name: "小芳", age: 13}
	var s3 Student = Student{"小红", 12}
	fmt.Println(s2)
	fmt.Println(s3)

	s4 := new(Student)
	s4.age = 23
	s4.name = "Jerry"

	s5 := &Student{}
	s5.name = "Bob"
	s5.age = 34

	relation := &People{
		name: "爷爷",
		child: &People{
			name: "爸爸",
			child: &People{
				name: "我",
			},
		},
	}
	fmt.Println(relation)

	var v int = 1
	cmd := newCommand("stop", &v, "stop successfully")
	fmt.Println(cmd)

	b := B{A{1, 2}, 3.0, 4.0}
	fmt.Println(b.ax, b.ay, b.bx, b.by)
	fmt.Println(b.A)
	fmt.Println(b.A.ax, b.A.ay)
}

func newCommand(name string, v *int, comment string) *Command {
	return &Command{
		Name:    name,
		Var:     v,
		Comment: comment,
	}
}
